package com.love_weinuo.util.glideutil;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.love_weinuo.R;

/**
 * Created by Administrator
 * on 2019/2/21.
 */

public class GlideUtil {

    public static void setResourceMethod(Context context, int id, ImageView image) {
        Glide.with(context)
                .asBitmap() 
                .load(id)
                .apply(new RequestOptions()
                        .transform(new GlideRoundTransform(context))
                        .placeholder(R.drawable.icon_guide_first)
                        .centerCrop())
                .into(image);
    }

    public static void setUriMethod(Context context, String url, ImageView image) {
        Glide.with(context)
                .asBitmap() 
                .load(url)
                .apply(new RequestOptions()
                        .placeholder(R.drawable.icon_guide_first)
                        .centerCrop())
                .into(image);
    }

    public static void setCircleMethod(Context context, String url, ImageView image) {
        Glide.with(context)
                .asBitmap() 
                .load(url)
                .apply(new RequestOptions()
                        .transform(new GlideCircleTransform(context))
                        .placeholder(R.drawable.icon_guide_first)
                        .centerCrop())
                .into(image);
    }

    public static void setCircleDrawableMethod(Context context, int id, ImageView image) {
        Glide.with(context)
                .load(id)
                .apply(new RequestOptions()
                        .transform(new GlideCircleTransform(context))
                        .placeholder(R.drawable.icon_guide_first)//替换一个加载失败的图片
                        .centerCrop())
                .into(image);
    }
}
